]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
location: Only ask user once
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 23 Feb 2016 17:29:47 +0000 (17:29 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 3 Mar 2016 16:06:20 +0000 (16:06 +0000)
Let's make it really simple and ask user interactively, once. This
simplifies things for:

* Privacy panel of gnome-control-center as it doesn't have to filter
  applications.

* Apps: If they are denied access, they can simply point users to
  privacy panel of gnome-control-center since they can be sure location
  access for the app can be enabled in there.

Also it's less annoying to user. Before this patch, if they denied
access to application, they had to keep doing that at least each time
they launched the application.

https://bugzilla.gnome.org/show_bug.cgi?id=762559

js/ui/status/location.js

index 666230890e1b9c1301695d067e074d27097b0026..00c1f42fad08abaaa1d9bb8e0c6df8bf1825f943 100644 (file)
@@ -286,7 +286,6 @@ const AppAuthorizer = new Lang.Class({
         this._maxAccuracyLevel = maxAccuracyLevel;
 
         this._accuracyLevel = GeoclueAccuracyLevel.NONE;
-        this._timesAllowed = 0;
     },
 
     authorize: function(onAuthDone) {
@@ -329,15 +328,14 @@ const AppAuthorizer = new Lang.Class({
         [this._permissions] = result;
         let permission = this._permissions[this.desktopId];
 
-        let [levelStr, timeStr] = permission || ['NONE', '0'];
-        this._accuracyLevel = GeoclueAccuracyLevel[levelStr] ||
-                              GeoclueAccuracyLevel.NONE;
-        this._timesAllowed = Number(timeStr) || 0;
-
-        if (this._timesAllowed < 3)
+        if (permission == null) {
             this._userAuthorizeApp();
-        else
+        } else {
+            let [levelStr] = permission || ['NONE'];
+            this._accuracyLevel = GeoclueAccuracyLevel[levelStr] ||
+                                  GeoclueAccuracyLevel.NONE;
             this._completeAuth();
+        }
     },
 
     _userAuthorizeApp: function() {
@@ -368,7 +366,6 @@ const AppAuthorizer = new Lang.Class({
             this._accuracyLevel = clamp(this._accuracyLevel,
                                         0,
                                         this._maxAccuracyLevel);
-            this._timesAllowed++;
         }
         this._saveToPermissionStore();
 
@@ -379,15 +376,10 @@ const AppAuthorizer = new Lang.Class({
         if (this._permStoreProxy == null)
             return;
 
-        if (this._accuracyLevel != GeoclueAccuracyLevel.NONE) {
-            let levelStr = accuracyLevelToString(this._accuracyLevel);
-            let dateStr = Math.round(Date.now() / 1000).toString();
-            this._permissions[this.desktopId] = [levelStr,
-                                                 this._timesAllowed.toString(),
-                                                 dateStr];
-        } else {
-            delete this._permissions[this.desktopId];
-        }
+        let levelStr = accuracyLevelToString(this._accuracyLevel);
+        let dateStr = Math.round(Date.now() / 1000).toString();
+        this._permissions[this.desktopId] = [levelStr, dateStr];
+
         let data = GLib.Variant.new('av', {});
 
         this._permStoreProxy.SetRemote(APP_PERMISSIONS_TABLE,